<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      /*   function fn1(a){
            console.log(a);
            console.log('a');
        }
        fn1(1) */
        // 调用属性
        var obj={
            uname:'张三',
            age:18,
            sex:'男',
            fn:function(){
                console.log('你是谁？');
            }
        }
        console.log(obj.uname);
        console.log(obj['fn']);
        console.log(obj.age);
        console.log(obj['uname']);
        obj.fn()
        var obj={
            uname:'可可',
            type:'阿拉斯加',
            age:5,
            color:'棕红色',
            get:function(){
                console.log('bark');
                console.log('showFilm');
            }
            
        }
        console.log(obj.uname);
        console.log(obj.age);
        console.log(obj['color']);

        // 第二种方法
        var obj=new Object()
        obj.name='张三'
        obj.age=20
        obj.sex='男'
        obj.fn=function(){
            console.log('你到底是谁？');

        }
console.log(obj.name);
console.log(obj['age']);
console.log(obj.sex);
obj.fn()
        
var obj=new Object()
obj.name='鸣人'
obj.sex='男'
obj.age=19+'岁'
obj.skill=function(){
    console.log('影分身术');
}
console.log(obj.name);
console.log(obj['age']);
console.log(obj.sex);
obj.skill()

/* function str(name,type,blood){
this. name=name
this.type=type
this.blood=blood
this.attack=function(gj){
    console.log(gj);
}
}
var lp=new str('廉颇',500,'近战')
console.log(lp.name);
console.log(lp.type);
console.log(lp['blood']);
lp.attack('力量')
var hy=new str('后裔',100,'远程')
console.log(hy.name);
console.log(hy['type']);
console.log(hy.blood);
hy.attack('力量') */
/* function getstr(name,type,blood){
    this.name=name;
    this.type=type;
    this.blood=blood;
    this.attack=function(fn){
        console.log(fn);
    }
}
var lp=new getstr('廉颇','力量型','500血量')
console.log(lp.name);
console.log(lp['type']);
console.log(lp.blood);
lp.attack('近战')
var hy=new getstr('后裔','射手型','100血量')
console.log(hy.name);
console.log(hy['type']);
console.log(hy.blood);
hy.attack('远程') */
/* var obj={
    name:'张三',
    age:18,
    sex:'男'

}
for(var k in obj){
    console.log(obj[k]);
}

 */
function Getdn(color,zhl,pinp,xh){
    this.color=color
    this.zhl=zhl
    this.pinp=pinp
    this.xh=xh
    this.fn=function(dy,yinye,youx,dm){
        console.log(dy,yinye,youx,dm);
    }
}
var dian=new Getdn('红色','18kg','联想','thingkbook')
console.log(dian.color);
console.log(dian.zhl);
console.log(dian.pinp);
console.log(dian.xh);
dian.fn('看电影','听音乐','打游戏','敲代码')
    </script>
</body>
</html>